<?php
/*
	插件概览
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
set_html('title','登录门店');
if($_RQ['op']=='get'){
	$return['set']=$this->plugin_setting('basice');
	$return['set']['loginlogo']=tomedia($return['set']['loginlogo']);
	$return['set']['loginbg']=tomedia($return['set']['loginbg']);
	if($_SESSION['os']=='windows'){
		$return['session_id']=session_id();
	}
	if($_SESSION['uid'] && !$_RQ['loginup']){
		exi('','error','jy_kongtiaoshop/store.index/');
	}
	$_SESSION['logout_forward']='jy_kongtiaoshop/store.login/';
	$_SESSION['forward_url']='jy_kongtiaoshop/store.index/'; 
	$return['forward_url']=base64_encode($_SESSION['forward_url']);
	$return['info']=array();
	$return['openid']=$_SESSION['openid'];
	exi($return);
}
if($_RQ['op']=='post'){
	$post=get_postdata();
	if(!$post['upass'] || !$post['uname']){
		exi('请填写店长名和密码','error');
	}
	$store=pdo_get('jy_weishop_store',array('uniacid'=>$_SESSION['uniacid'],'uname'=>$post['uname']));
    if($post['upass']!=base64_decode($store['upass'])){
    	exi('用户名或密码错误','error');
    }
    if(!$store['mid']){
        exi('该门店没有绑定店长会员！请联系平台客服！','error');
    }
	$_SESSION['uid']=$store['mid'];
 	$_SESSION['storeid']=$store['id'];
	$_SESSION['member']['username']=$store['uname'];
	$url= custom_url('jy_kongtiaoshop/store.index/',true);
	exi('登陆成功!','',$url);
}